<?php 
$index_categories = array();
foreach ($link_categories as $k=>$v){
		$index_categories[$k] = array('category_name'=>$v['category_name'],
									  'category_url_link'=>$v['category_url_link'],
									  'categories_image'=>$v['categories_image'],
									  'has_sub_cate'=>$v['has_sub_cate'],
									  'sub_count'=>$v['sub_count'],
									  'sub_categories'=>array()
		);
		if(1 != $v['c_level']){
			$index_categories[$v['parent_id']]['sub_categories'][$k] = $index_categories[$k];
			unset($index_categories[$k]);
		}

}
if(isset($index_categories) && is_array($index_categories) && sizeof($index_categories)>0){
      $cnt_limit_1=1;
?>
<div id="index_categories">
   <h6><?php echo TEXT_RECOMMEND_CATEGORIES;?></h6>
   
      <?php 
	    foreach($index_categories as $category){
		   $cnt_limit_2=1;
		   if(!$category['has_sub_cate']) continue;
		   if($cnt_limit_1>6) break;
	  ?>
	  <dl <?php echo (($cnt_limit_1 % 3 == 0)?'class="third"':'')?> >
	  <dt>
	    <a href="<?php echo $category['category_url_link'];?>" class="ih">
		  <?php if(zen_not_null($category['categories_image'])) echo zen_image(HTTP_SERVER.DIR_WS_CATALOG.DIR_WS_IMAGES.$category['categories_image'],$category['category_name'],170);?>
		</a>
		</dt>
		<dd>
		<h2 class="main-category">
		<a href="<?php echo $category['category_url_link'];?>" title=""><?php echo $category['category_name'];?></a>
		</h2>
		<ul>
		  <?php foreach($category['sub_categories'] as $sub_category){
		        if($cnt_limit_2>5) break;
		   ?>
		   <li>
		   <h3>
			<a href="<?php echo $sub_category['category_url_link'];?>" title="">
				   <span></span>
					  <?php echo zen_trunc_string($sub_category['category_name'],50,true);?>
				   </a> 
				   </h3>
				   </li>
		  <?php 
		        $cnt_limit_2++;
		        }
		   ?>
		</ul>
		</dd>
	  </dl>
	  <?php echo (($cnt_limit_1 == 3)?'<div class="clearfix separate"></div>':'')?>
	  <?php 
	       $cnt_limit_1++;
	       }
	   ?>
    
</div>
<?php }?>